# 版本1 使用python 函数实现js功能

# import requests
# import base64
#
# info = input("输入发送原始信息")
# info_base64 = base64.b64encode(info.encode('utf-8'))
# res = requests.get(f'https://httpbin.org/get?ID=12345&info={info_base64}')
# print(res.json())




# import requests
# import execjs
#
#
# info = input("输入发送原始信息")
# # 通过js 代码 对info处理
#
# js_str = """
#         function do_str(str){
#             // 将字符串转换为数组
#             const arr = str.split('');
#
#             // Fisher-Yates 洗牌算法
#             for (let i = arr.length - 1; i > 0; i--) {
#                 const j = Math.floor(Math.random() * (i + 1));
#                 // 交换元素
#                 [arr[i], arr[j]] = [arr[j], arr[i]];
#             }
#
#             // 将数组转换回字符串
#             return arr.join('');
#         }
# """
#
# js_code = execjs.compile(js_str)
#
# # 调用js 函数 do_str   处理info
# r = js_code.call('do_str', info)
# print(r)
#
#
# res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
# print(res.json())



# import requests
# import execjs
#
#
# info = input("输入发送原始信息")
# # 通过js 代码 对info处理
#
# js_str = """
#         function _0x325e(_0x2ba218,_0x549760){var _0x96df20=_0x96df();return _0x325e=function(_0x325e8d,_0x314fc1){_0x325e8d=_0x325e8d-0x1c5;var _0x474fd5=_0x96df20[_0x325e8d];return _0x474fd5;},_0x325e(_0x2ba218,_0x549760);}(function(_0x2e60d2,_0x596176){var _0xb43e8c=_0x325e,_0x119c81=_0x2e60d2();while(!![]){try{var _0x122179=-parseInt(_0xb43e8c(0x1c9))/0x1+-parseInt(_0xb43e8c(0x1c6))/0x2*(parseInt(_0xb43e8c(0x1cb))/0x3)+parseInt(_0xb43e8c(0x1ce))/0x4+-parseInt(_0xb43e8c(0x1c5))/0x5+-parseInt(_0xb43e8c(0x1cc))/0x6*(-parseInt(_0xb43e8c(0x1c8))/0x7)+-parseInt(_0xb43e8c(0x1cf))/0x8*(-parseInt(_0xb43e8c(0x1c7))/0x9)+parseInt(_0xb43e8c(0x1cd))/0xa;if(_0x122179===_0x596176)break;else _0x119c81['push'](_0x119c81['shift']());}catch(_0x50434c){_0x119c81['push'](_0x119c81['shift']());}}}(_0x96df,0x7d8c2));function say_hi(_0x147018){var _0x41f23f=_0x325e;return _0x41f23f(0x1ca)+_0x147018;}function _0x96df(){var _0x3034d7=['56hsNimv','978808LNTcIZ','hello\x20world','1994898GYtbYJ','217218rfGRbo','15201650jKzrPv','3249644deoMCS','1865288KqsQCc','3486725OZdKGF','2uJlpDo','9QCsqIK'];_0x96df=function(){return _0x3034d7;};return _0x96df();}
# """
#
# js_code = execjs.compile(js_str)
#
# # 调用js 函数 do_str   处理info
# r = js_code.call('say_hi', info)
# print(r)
#
#
# res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
# print(res.json())




# import requests
# import execjs
#
#
# info = input("输入发送原始信息")
# # 通过js 代码 对info处理
#
# js_str = """
#             var window = {
#                 navigator: {
#                     userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
#                 },
#                 document: {
#                     cookie: "csrftoken=1H6tdIUiVRuckeg044kikR8NrLyFYAo5"
#                 }
#             };
#
#             function _0x2b77(_0x20e79e,_0x841523){const _0x3fdbbd=_0x3fdb();return _0x2b77=function(_0x2b7727,_0x3f599a){_0x2b7727=_0x2b7727-0x168;let _0x3a78b4=_0x3fdbbd[_0x2b7727];return _0x3a78b4;},_0x2b77(_0x20e79e,_0x841523);}(function(_0x2f8ec6,_0x1b2d56){const _0x1bf6c6=_0x2b77,_0x3090d0=_0x2f8ec6();while(!![]){try{const _0x42899b=-parseInt(_0x1bf6c6(0x174))/0x1*(-parseInt(_0x1bf6c6(0x176))/0x2)+parseInt(_0x1bf6c6(0x169))/0x3*(parseInt(_0x1bf6c6(0x16f))/0x4)+parseInt(_0x1bf6c6(0x16d))/0x5*(parseInt(_0x1bf6c6(0x16b))/0x6)+parseInt(_0x1bf6c6(0x16c))/0x7*(-parseInt(_0x1bf6c6(0x177))/0x8)+-parseInt(_0x1bf6c6(0x16e))/0x9*(parseInt(_0x1bf6c6(0x168))/0xa)+parseInt(_0x1bf6c6(0x16a))/0xb+-parseInt(_0x1bf6c6(0x170))/0xc*(-parseInt(_0x1bf6c6(0x171))/0xd);if(_0x42899b===_0x1b2d56)break;else _0x3090d0['push'](_0x3090d0['shift']());}catch(_0x10636c){_0x3090d0['push'](_0x3090d0['shift']());}}}(_0x3fdb,0x6bcad));function userAgent_cookie(_0x4e1ae1){const _0x37573d=_0x2b77;let _0x2b47bf=window[_0x37573d(0x173)][_0x37573d(0x175)]+_0x4e1ae1+window['document'][_0x37573d(0x172)];return _0x2b47bf;}function _0x3fdb(){const _0x17b05d=['9919TRgJAc','cookie','navigator','2029rzQGAC','userAgent','790IMHPby','129448GfFRWd','7930330rRtYXJ','1110393kKidwn','361999KQSLfh','222RGsjOn','210vpsNWY','51410QILeBc','9RrBSJD','4rANMTR','2124QVuseb'];_0x3fdb=function(){return _0x17b05d;};return _0x3fdb();}
# """
#
# js_code = execjs.compile(js_str)
#
# # 调用js 函数 do_str   处理info
# r = js_code.call('userAgent_cookie', info)
# print(r)
#
#
# res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
# print(res.json())


import requests
import execjs

info = input("输入发送原始信息")
# 通过js 代码 对info处理

with open(f'./parse/1.js逆向原理.js', 'r', encoding='utf-8') as f:
    js_str = f.read()

js_code = execjs.compile(js_str, cwd="./parse")

# 调用js 函数 do_str   处理info
r = js_code.call('encrypt', info)
print(r)

res = requests.get(f'https://httpbin.org/get?ID=12345&info={r}')
print(res.json())